package yunhe.biz;

import java.util.ArrayList;
import java.util.HashMap;

import org.apache.ibatis.session.SqlSession;

import yunhe.dao.CustomerInte;
import yunhe.entity.Customer;
import yunhe.util.SqlSessionFactoryUtil;

public class CusBiz {
	SqlSession sqlSession=SqlSessionFactoryUtil.getSqlSession();
	CustomerInte cusInte=sqlSession.getMapper(CustomerInte.class);
	/**
	 * 添加客户
	 * @param product
	 * @return
	 */
	public boolean addCus(Customer customer) {
		if (cusInte.addCustomer(customer)) {
			System.out.println("cg");
			return true;
		}else {
			return false;
		}
	}
	/**
	 * 删除客户
	 * @param proBarCode
	 * @return
	 */
	public boolean delCus(String cusId) {
		if (cusInte.delCustomer("12345678905526")) {
			System.out.println("cg");
			return true;
		}else {
			return false;
		}
	}
	/**
	 * 更改客户
	 * @param product
	 * @return
	 */
	public boolean updateCus(Customer customer) {
		if (cusInte.updateCustomer(customer)) {
			System.out.println("cg");
			return true;
		}else {
			return false;
		}
	}
	/**
	 * 查询所有客户
	 * @return
	 */
	public ArrayList<Customer> getAllCus(HashMap<String,String> searchMap) {
		ArrayList<Customer> cusList=cusInte.getAllCustomer(searchMap);
		return cusList;
	}
	/**
	 * 分页查询客户
	 * @param curPage
	 * @param pageSize
	 * @return
	 */
	public ArrayList<Customer> getCustomerByPage(int curPage, int pageSize){
		ArrayList<Customer> cusList=cusInte.getCustomerByPage(curPage, pageSize);
		return cusList;
	}
	/**
	 * 查询客户总条数
	 * @return
	 */
	public int getCusCount(){
		return cusInte.getCusCount();
	}
}
